'use strict';
const db = uniCloud.database()
const dbCmd = db.command
exports.main = async (event, context) => {
	const collection = db.collection('bills-list')
	let res
	if(event.dateRange){
		let [gte,lte] = event.dateRange
		delete event.dateRange
		res = await collection.where({
			owner: event.owner,
			date: dbCmd.lte(lte).gte(gte)
		}).get()
	}else{
		res = await collection.where(event).get()
	}
	return res
};
